import axios from '@u/request'
//请求所有分类
const fetchCates = (params = {})=>{
  return axios.get('/shop/goods/category/all',{params})
}
//轮播
const fetchHomeBanner = (params={})=>{
  return axios.get('/banner/list',{params})
}

//请求所有商品 
const fetchList = (params={})=>{
  return axios.post('/shop/goods/list/v2',params)
}
//请求商品详情 
const fetchdetail = (params={})=>{
  return axios.get('/shop/goods/detail',{params})
}
//加入购物车
const addCart =  (params = {}) => {
  return axios.post('/shopping-cart/add', params)
}
// 用户登录
const doLogin = (params = {}) => {
  return axios.post('/user/username/login', params)
}
// 用户注册
const doRegister = (params = {}) => {
  return axios.post('/user/username/register', params)
}
//获取用户详情 /user/detail
const userdetail = (params={})=>{
  return axios.get('/user/detail',{params})
}
// 获取用户购物车数据
const fetchCartInfo = (params = {}) => {
  return axios.get('/shopping-cart/info', {params})
} 
// 增加购物车商品购买数量
const modifyCartNum =  (params = {}) => {
  return axios.post('/shopping-cart/modifyNumber', params)
}
// 删除购物车中商品
const removeCartItem = (params = {}) => {
  return axios.post('/shopping-cart/remove', params)
}
// 修改购物车商品选中状态
const modifyCartItemSelected = (params = {}) => {
  return axios.post('/shopping-cart/select', params)
}
export{
  fetchCates,
  fetchHomeBanner,
  fetchList,
  fetchdetail,
  addCart,
  doLogin,
  doRegister,
  fetchCartInfo,
  modifyCartNum,
  removeCartItem,
  modifyCartItemSelected,
  userdetail
}